package com.lysj.print.print.repository;

import com.lysj.admin.utils.spring.foundation.base.BaseRepository;
import com.lysj.admin.utils.web.SelectItem;
import com.lysj.print.print.domain.PrintArea;
import com.lysj.print.print.domain.Printer;
import com.lysj.print.print.vo.PrintAreaVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author Created by drj on 2019-03-15 16:44:47
 * @description 打印区域dao
 */
public interface PrintAreaRepository extends BaseRepository<PrintArea> {

    //获取对应门店打印机列表
    @Query(value = "select new com.lysj.print.print.vo.PrintAreaVo(a.id,a.name,a.printerId,b.name) FROM PrintArea a ,Printer b  WHERE a.storeId=?1 AND a.delFlag=1 AND a.printerId=b.id  ORDER BY a.createTime DESC ")
    Page<PrintAreaVo> findStoreAreaList(Pageable pageable, String storeId);

    /**
     * @author Created by wtl on 2019/4/12 10:19
     * @Description 获取门店的区域
     */
    @Query("select new com.lysj.admin.utils.web.SelectItem(id,name) from PrintArea where storeId=?1")
    List<SelectItem> findByStoreId(String storeId);


}